<?php

class Test
{
    public function foo()
    {
        
    }
}

class BenchReflection implements Benchmark
{
    private
        $test;
    
    public function __construct()
    {
        $this->test = new Test();
    }
    
    /**
     * @Benchcase(name='Dynamical call', color='red')
     */
    public function dynamical()
    {
        $method = 'foo';
        $this->test->$method();
    }
    
    /**
     * @Benchcase(name='Direct call', color='orange')
     */
    public function direct()
    {
        $this->test->foo();
    }
    
    /**
     * @Benchcase(name='Reflection API', color='blue')
     */
    public function reflection()
    {
        $reflect = new ReflectionClass('Test');
        $mthd = $reflect->getMethod('foo')->invoke($this->test);
    }
    
    /**
     * @Benchcase(name='PHP Core function', color='green')
     */
    public function core()
    {
        call_user_func(array($this->test, 'foo') );
    }
    
}